package testClasses.misc;

import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;

import testClasses.ATest;
import testClasses.TestingSystem;
import utilities.CustomMesh;
import utilities.Key;

import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.BloomFilter;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.Mesh.Mode;
import com.jme3.texture.Texture;

import controller.AbstractController;



public class LineTest extends ATest {
	
	private static final Logger logger = Logger.getLogger(LineTest.class.getName());
	
	public LineTest(TestingSystem system) {
		super(system);
		name = "Linetest";
		logger.log(Level.INFO, "LineTesting: Created");
		// TODO Auto-generated constructor stub
	}

	@Override
	public boolean execute() {
		logger.log(Level.INFO, "LineTesting: execute()");
		
		HashMap<Key, AbstractController> controllerMap = new HashMap<Key, AbstractController>();		
		eventManager.addControlMapReference(controllerMap);
		
		CustomMesh lineMesh = new CustomMesh(2);
		lineMesh.setMode(Mode.LineLoop);
		
		lineMesh.addVertex(0,0,0);
		lineMesh.addVertex(100,0,0);				
		lineMesh.addVertex(0,100,0);
		lineMesh.addVertex(100,100,0);
		
		//lineMesh.setColor(ColorRGBA.Green);
		
		lineMesh.setLineWidth(3.0f);
		
		lineMesh.finish();
		lineMesh.setStatic();
		
		Geometry geo = new Geometry("5", lineMesh);
		//Material mat = new Material(assets, "Common/MatDefs/Misc/Unshaded.j3md");
		Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
		mat.setColor("Color", ColorRGBA.Blue);
		mat.setColor("GlowColor", ColorRGBA.Blue);
//		FilterPostProcessor fpp = new FilterPostProcessor(assets);
//		BloomFilter bloom = new BloomFilter(BloomFilter.GlowMode.Objects);
//		fpp.addFilter(bloom);
	
		//Texture tex = assets.loadTexture("assets/Graphics/Map/CandyCane.png");
		
		//mat.setTexture("candycan", tex);
		//mat.setBoolean("VertexColor", true);
		geo.setMaterial(mat);
		node.attachChild(geo);
		
		return true;
	}

}
